#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :schemas.py
# @Time      :2021/04/06 14:18:55
# @Author    :Raink
# 基于pydantic， 响应体的数据格式，与models里的模型类对应
# 03


from datetime import datetime
from datetime import date as date_
from pydantic import BaseModel

"""-----------创建数据类----------"""
"""
创建数据的时候updated_at和created_at会自动生成
Data中的city_id，由CreateCity先创建，然后再获取
"""
class CreateData(BaseModel):
    date: date_
    confirmed: int = 0
    deaths: int = 0
    recovered: int = 0


class CreateCity(BaseModel):
    province: str
    country: str
    country_code: str
    country_population: int

"""-----------查询数据类----------"""

class ReadData(CreateData):
    id: int
    city_id: int
    updated_at: datetime
    created_at: datetime

    class Config:
        orm_mode = True

class ReadCity(CreateCity):
    id: int
    updated_at: datetime
    created_at: datetime

    class Config:
        orm_mode = True